package myJs.myPkg.i18n

import myJs.Implicits.JDJAn
import slinky.readwrite.ObjectOrWritten

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

/**
 * Created by yz on 28/3/2022
 */

@js.native
trait i18n extends js.Object {

  def init(options: ObjectOrWritten[InitOptions]): js.Promise[TF] = js.native

}

case class ReactOptions(useSuspense: Boolean)

case class InterpolationOptions(escapeValue: Boolean)

case class InitOptions(resources: JDJAn, fallbackLng: String, lng: String, react: ReactOptions,
                       interpolation: InterpolationOptions)

@js.native
@JSImport("i18next", JSImport.Default)
object i18n extends js.Object {

  def use[T](module: T): i18n = js.native

}

@js.native
trait TF extends js.Object {

  def apply[K, V](k: K): V = js.native

  def apply[K, V](k: K,options:JDJAn): V = js.native

}

@js.native
trait ThirdPartyModule extends js.Object

@js.native
@JSImport("react-i18next", JSImport.Default)
object ReactI18next extends js.Object {

  def useTranslation(): js.Tuple3[TF, i18n, Boolean] = js.native

  val initReactI18next: ThirdPartyModule = js.native

}
